<template>
    <div class="all">
        <div class="head">
            <div class="tab" @click="toRouter('/welcome')">车辆管理系统</div>
            <div class="tab" @click="toRouter('/zhandian')">站点设置</div>
            <div class="tab" @click="toRouter('/cheliang')">车辆管理</div>
            <div class="tab" @click="toRouter('/caiwu')">财务管理</div>
            <div class="tab" @click="toRouter('/manage')">管理员管理</div>
            <div class="tab" @click="toRouter('/user')">用户管理</div>
            <div class="tab" @click="toRouter('/qrcode')">二维码管理</div>
            <div class="userlogin" >{{ userName }}<span style="margin-left: 20px;cursor: pointer;" @click="logout">退出登录</span></div>
        </div>
        <div class="content">
                <router-view></router-view>
        </div>
    </div>
</template>

<script setup>
import { onMounted ,ref } from 'vue'
import { useRouter } from 'vue-router'

const userName = ref()

const router = useRouter()

const toRouter = (a) => {
    router.push(a)
}

//退出登陆
const logout = ()=>{
    // 在用户登出时清除 token
    localStorage.removeItem('token');
    localStorage.removeItem('username');
    router.push('/login')

}
// const dongtaiName = ref()



onMounted(()=>{
    userName.value = localStorage.getItem("username")
    console.log(userName)
})

</script>

<style lang="scss" scoped>


   
.head{
    width: 100%;
    // position: fixed;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap-reverse;
    background: #18bc9c;
    color: #fff;
    .tab{
        height: 60px;
        width: 80px;
        padding: 0 10px;
        text-align: center;
        line-height: 60px;
        margin: 0 20px;
        &:hover{
            color: red;
            background-color: rgb(179, 205, 179);
            cursor: pointer;
        }
    }
    .userlogin{
        height: 60px;
        line-height: 60px;
    }

    p{
        position: absolute;
        right: 20px;
        line-height: 60px;
        span{
           &:hover{
               color: red;
               background-color: rgb(179, 205, 179);
               cursor: pointer;
           }
        }
    }
}
.content{
    box-sizing: border-box;
    // padding-top: 60px;
    width: 100%;
    height: calc(100vh - 60px);
    background-color: pink;
    display: flex;
    .left{
        background-color: #6d6161;
        height: 100%;
        width: 200px;
    }
    .right{
        background-color: #ffffff;
        height: 100%;
        width: 100%;
    }
}

@media screen and (max-width: 768px) {
    .head {
        // align-content: space-around;
        justify-content: center;
        div{
            height: 30px;
            line-height: 30px;
            padding: 0;
        }
    }
}

</style>